if (!("finalizeConstruction" in ViewPU.prototype)) {
    Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { });
}
import { ScanBottomLeftRect, ScanBottomRightRect, ScanTopLeftRect, ScanTopRightRect } from './ScanRectView';
import customScan from "@hms.core.scan.customScan";
import scanCore from "@hms.core.scan.scanCore";
import display from "@ohos.display";
import { requestPermissionsFromUser } from '../../Utils/scannerUtils/PermissionUtil';
import { ScanUtil } from '../../Utils/scannerUtils/ScanUtil';
import { ResultState } from '../../Utils/scannerUtils/ResultState';
import image from "@ohos.multimedia.image";
import { calculateLuminance } from '../../Utils/scannerUtils/ImageUtil';
import photoAccessHelper from "@ohos.file.photoAccessHelper";
export class Scanner extends ViewPU {
    constructor(d12, e12, f12, g12 = -1, h12 = undefined, i12) {
        super(d12, f12, g12, i12);
        if (typeof h12 === "function") {
            this.paramsGenerator_ = h12;
        }
        this.__albumsShow = new SynchedPropertySimpleOneWayPU(e12.albumsShow, this, "albumsShow");
        this.__albumsIcon = new SynchedPropertyObjectOneWayPU(e12.albumsIcon, this, "albumsIcon");
        this.__albumsIconSize = new SynchedPropertyObjectOneWayPU(e12.albumsIconSize, this, "albumsIconSize");
        this.__albumsText = new SynchedPropertySimpleOneWayPU(e12.albumsText, this, "albumsText");
        this.__albumsTextSize = new SynchedPropertyObjectOneWayPU(e12.albumsTextSize, this, "albumsTextSize");
        this.__albumsTextColor = new SynchedPropertyObjectOneWayPU(e12.albumsTextColor, this, "albumsTextColor");
        this.__lightShow = new SynchedPropertySimpleOneWayPU(e12.lightShow, this, "lightShow");
        this.__lightCloseIcon = new SynchedPropertyObjectOneWayPU(e12.lightCloseIcon, this, "lightCloseIcon");
        this.__lightOpenIcon = new SynchedPropertyObjectOneWayPU(e12.lightOpenIcon, this, "lightOpenIcon");
        this.__lightIconSize = new SynchedPropertyObjectOneWayPU(e12.lightIconSize, this, "lightIconSize");
        this.__lightOpenText = new SynchedPropertySimpleOneWayPU(e12.lightOpenText, this, "lightOpenText");
        this.__lightCloseText = new SynchedPropertySimpleOneWayPU(e12.lightCloseText, this, "lightCloseText");
        this.__lightTextSize = new SynchedPropertyObjectOneWayPU(e12.lightTextSize, this, "lightTextSize");
        this.__lightTextColor = new SynchedPropertyObjectOneWayPU(e12.lightTextColor, this, "lightTextColor");
        this.__tipsShow = new SynchedPropertySimpleOneWayPU(e12.tipsShow, this, "tipsShow");
        this.__tips = new SynchedPropertySimpleOneWayPU(e12.tips, this, "tips");
        this.__tipsTextColor = new SynchedPropertyObjectOneWayPU(e12.tipsTextColor, this, "tipsTextColor");
        this.__tipsTextSize = new SynchedPropertyObjectOneWayPU(e12.tipsTextSize, this, "tipsTextSize");
        this.__tipsTopMargin = new SynchedPropertyObjectOneWayPU(e12.tipsTopMargin, this, "tipsTopMargin");
        this.__maskColor = new SynchedPropertyObjectOneWayPU(e12.maskColor, this, "maskColor");
        this.__scannerSize = new SynchedPropertySimpleOneWayPU(e12.scannerSize, this, "scannerSize");
        this.__cornerLineWidth = new SynchedPropertySimpleOneWayPU(e12.cornerLineWidth, this, "cornerLineWidth");
        this.__cornerLineLength = new SynchedPropertySimpleOneWayPU(e12.cornerLineLength, this, "cornerLineLength");
        this.__cornerLineColor = new SynchedPropertyObjectOneWayPU(e12.cornerLineColor, this, "cornerLineColor");
        this.__cornerLineShow = new SynchedPropertySimpleOneWayPU(e12.cornerLineShow, this, "cornerLineShow");
        this.__scanTopMargin = new SynchedPropertySimpleOneWayPU(e12.scanTopMargin, this, "scanTopMargin");
        this.__scanLineWidth = new SynchedPropertyObjectOneWayPU(e12.scanLineWidth, this, "scanLineWidth");
        this.__scanLineLength = new SynchedPropertyObjectOneWayPU(e12.scanLineLength, this, "scanLineLength");
        this.__scanLineColor = new SynchedPropertyObjectOneWayPU(e12.scanLineColor, this, "scanLineColor");
        this.__scanLineShow = new SynchedPropertySimpleOneWayPU(e12.scanLineShow, this, "scanLineShow");
        this.__scanAnimTime = new SynchedPropertySimpleOneWayPU(e12.scanAnimTime, this, "scanAnimTime");
        this.__scanIntervalTime = new SynchedPropertySimpleOneWayPU(e12.scanIntervalTime, this, "scanIntervalTime");
        this.__onceScan = new SynchedPropertySimpleOneWayPU(e12.onceScan, this, "onceScan");
        this.__scanTypes = new SynchedPropertyObjectOneWayPU(e12.scanTypes, this, "scanTypes");
        this.__safeAreaType = new SynchedPropertyObjectOneWayPU(e12.safeAreaType, this, "safeAreaType");
        this.__safeAreaEdge = new SynchedPropertyObjectOneWayPU(e12.safeAreaEdge, this, "safeAreaEdge");
        this.__luminanceAnalyzerInterval = new SynchedPropertySimpleOneWayPU(e12.luminanceAnalyzerInterval, this, "luminanceAnalyzerInterval");
        this.luminanceListener = undefined;
        this.disableCheckArea = false;
        this.areaOffset = 100;
        this.controller = undefined;
        this.onScanResult = undefined;
        this.onCameraGrant = undefined;
        this.onCameraReject = undefined;
        this.__scanLineY = new ObservedPropertySimplePU(0, this, "scanLineY");
        this.mXComponentController = new XComponentController();
        this.surfaceId = undefined;
        this.viewControl = undefined;
        this.defaultWidth = 360;
        this.defaultHeight = 640;
        this.__screenWidth = new ObservedPropertySimplePU(this.defaultWidth, this, "screenWidth");
        this.__screenHeight = new ObservedPropertySimplePU(this.defaultHeight, this, "screenHeight");
        this.__isLoaded = new ObservedPropertySimplePU(false, this, "isLoaded");
        this.__isLightOpen = new ObservedPropertySimplePU(false, this, "isLightOpen");
        this.__scanRectLeftBoundary = new ObservedPropertySimplePU(0, this, "scanRectLeftBoundary");
        this.__scanRectRightBoundary = new ObservedPropertySimplePU(0, this, "scanRectRightBoundary");
        this.__scanRectTopBoundary = new ObservedPropertySimplePU(0, this, "scanRectTopBoundary");
        this.__scanRectBottomBoundary = new ObservedPropertySimplePU(0, this, "scanRectBottomBoundary");
        this.__firstShow = new ObservedPropertySimplePU(true, this, "firstShow");
        this.__isRelease = new ObservedPropertySimplePU(false, this, "isRelease");
        this.__isFirstScanSuccess = new ObservedPropertySimplePU(false, this, "isFirstScanSuccess");
        this.scanConsumed = true;
        this.luminanceAnalyzerId = 0;
        this.callback = async (j12, k12) => {
            this.scanConsumed = true;
            if (this.isRelease) {
                return;
            }
            if (j12) {
                console.warn(`扫描错误, code: ${j12.code}, message: ${j12.message}`);
                if (j12.code != 1000500001) {
                    this.onScanResult?.(ResultState.Fail, j12.message);
                }
                if (!this.isRelease) {
                    this.rescan();
                }
                return;
            }
            console.log(`扫描成功, result: ${JSON.stringify(k12)}`);
            if (k12) {
                let l12 = k12[0]?.scanCodeRect;
                if (l12 != undefined && (this.disableCheckArea || this.isInScanRect(px2vp(l12.left), px2vp(l12.top), px2vp(l12.right), px2vp(l12.bottom)))) {
                    if (k12[0]?.originalValue != undefined) {
                        if (this.onceScan) {
                            if (!this.isFirstScanSuccess) {
                                this.onScanResult?.(ResultState.Success, k12[0]?.originalValue);
                            }
                            this.isFirstScanSuccess = true;
                        }
                        else {
                            this.onScanResult?.(ResultState.Success, k12[0]?.originalValue);
                        }
                    }
                    else {
                        this.onScanResult?.(ResultState.Fail, '扫描错误');
                    }
                }
            }
            if (!this.isRelease) {
                this.rescan();
            }
        };
        this.setInitiallyProvidedValue(e12);
        this.declareWatch("isLoaded", this.startScan);
        this.finalizeConstruction();
    }
    setInitiallyProvidedValue(c12) {
        if (c12.albumsShow === undefined) {
            this.__albumsShow.set(true);
        }
        if (c12.albumsIcon === undefined) {
            this.__albumsIcon.set({ "id": -1, "type": 20000, params: ['app.media.scanner_albums'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" });
        }
        if (c12.albumsIconSize === undefined) {
            this.__albumsIconSize.set(64);
        }
        if (c12.albumsText === undefined) {
            this.__albumsText.set('相册');
        }
        if (c12.albumsTextSize === undefined) {
            this.__albumsTextSize.set(16);
        }
        if (c12.albumsTextColor === undefined) {
            this.__albumsTextColor.set(Color.White);
        }
        if (c12.lightShow === undefined) {
            this.__lightShow.set(true);
        }
        if (c12.lightCloseIcon === undefined) {
            this.__lightCloseIcon.set({ "id": -1, "type": 20000, params: ['app.media.scanner_light_close'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" });
        }
        if (c12.lightOpenIcon === undefined) {
            this.__lightOpenIcon.set({ "id": -1, "type": 20000, params: ['app.media.scanner_light_open'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" });
        }
        if (c12.lightIconSize === undefined) {
            this.__lightIconSize.set(64);
        }
        if (c12.lightOpenText === undefined) {
            this.__lightOpenText.set('开灯');
        }
        if (c12.lightCloseText === undefined) {
            this.__lightCloseText.set('关灯');
        }
        if (c12.lightTextSize === undefined) {
            this.__lightTextSize.set(16);
        }
        if (c12.lightTextColor === undefined) {
            this.__lightTextColor.set(Color.White);
        }
        if (c12.tipsShow === undefined) {
            this.__tipsShow.set(true);
        }
        if (c12.tips === undefined) {
            this.__tips.set('将条码、二维码放入框内，即可自动扫描');
        }
        if (c12.tipsTextColor === undefined) {
            this.__tipsTextColor.set(Color.White);
        }
        if (c12.tipsTextSize === undefined) {
            this.__tipsTextSize.set(14);
        }
        if (c12.tipsTopMargin === undefined) {
            this.__tipsTopMargin.set(10);
        }
        if (c12.maskColor === undefined) {
            this.__maskColor.set('#7f000000');
        }
        if (c12.scannerSize === undefined) {
            this.__scannerSize.set(256);
        }
        if (c12.cornerLineWidth === undefined) {
            this.__cornerLineWidth.set(3);
        }
        if (c12.cornerLineLength === undefined) {
            this.__cornerLineLength.set(30);
        }
        if (c12.cornerLineColor === undefined) {
            this.__cornerLineColor.set(Color.White);
        }
        if (c12.cornerLineShow === undefined) {
            this.__cornerLineShow.set(true);
        }
        if (c12.scanTopMargin === undefined) {
            this.__scanTopMargin.set(100);
        }
        if (c12.scanLineWidth === undefined) {
            this.__scanLineWidth.set(1);
        }
        if (c12.scanLineLength === undefined) {
            this.__scanLineLength.set('100%');
        }
        if (c12.scanLineColor === undefined) {
            this.__scanLineColor.set(Color.White);
        }
        if (c12.scanLineShow === undefined) {
            this.__scanLineShow.set(true);
        }
        if (c12.scanAnimTime === undefined) {
            this.__scanAnimTime.set(1500);
        }
        if (c12.scanIntervalTime === undefined) {
            this.__scanIntervalTime.set(1000);
        }
        if (c12.onceScan === undefined) {
            this.__onceScan.set(false);
        }
        if (c12.scanTypes === undefined) {
            this.__scanTypes.set([scanCore.ScanType.ALL]);
        }
        if (c12.safeAreaType === undefined) {
            this.__safeAreaType.set([SafeAreaType.SYSTEM]);
        }
        if (c12.safeAreaEdge === undefined) {
            this.__safeAreaEdge.set([SafeAreaEdge.BOTTOM]);
        }
        if (c12.luminanceAnalyzerInterval === undefined) {
            this.__luminanceAnalyzerInterval.set(1000);
        }
        if (c12.luminanceListener !== undefined) {
            this.luminanceListener = c12.luminanceListener;
        }
        if (c12.disableCheckArea !== undefined) {
            this.disableCheckArea = c12.disableCheckArea;
        }
        if (c12.areaOffset !== undefined) {
            this.areaOffset = c12.areaOffset;
        }
        if (c12.controller !== undefined) {
            this.controller = c12.controller;
        }
        if (c12.onScanResult !== undefined) {
            this.onScanResult = c12.onScanResult;
        }
        if (c12.onCameraGrant !== undefined) {
            this.onCameraGrant = c12.onCameraGrant;
        }
        if (c12.onCameraReject !== undefined) {
            this.onCameraReject = c12.onCameraReject;
        }
        if (c12.scanLineY !== undefined) {
            this.scanLineY = c12.scanLineY;
        }
        if (c12.mXComponentController !== undefined) {
            this.mXComponentController = c12.mXComponentController;
        }
        if (c12.surfaceId !== undefined) {
            this.surfaceId = c12.surfaceId;
        }
        if (c12.viewControl !== undefined) {
            this.viewControl = c12.viewControl;
        }
        if (c12.defaultWidth !== undefined) {
            this.defaultWidth = c12.defaultWidth;
        }
        if (c12.defaultHeight !== undefined) {
            this.defaultHeight = c12.defaultHeight;
        }
        if (c12.screenWidth !== undefined) {
            this.screenWidth = c12.screenWidth;
        }
        if (c12.screenHeight !== undefined) {
            this.screenHeight = c12.screenHeight;
        }
        if (c12.isLoaded !== undefined) {
            this.isLoaded = c12.isLoaded;
        }
        if (c12.isLightOpen !== undefined) {
            this.isLightOpen = c12.isLightOpen;
        }
        if (c12.scanRectLeftBoundary !== undefined) {
            this.scanRectLeftBoundary = c12.scanRectLeftBoundary;
        }
        if (c12.scanRectRightBoundary !== undefined) {
            this.scanRectRightBoundary = c12.scanRectRightBoundary;
        }
        if (c12.scanRectTopBoundary !== undefined) {
            this.scanRectTopBoundary = c12.scanRectTopBoundary;
        }
        if (c12.scanRectBottomBoundary !== undefined) {
            this.scanRectBottomBoundary = c12.scanRectBottomBoundary;
        }
        if (c12.firstShow !== undefined) {
            this.firstShow = c12.firstShow;
        }
        if (c12.isRelease !== undefined) {
            this.isRelease = c12.isRelease;
        }
        if (c12.isFirstScanSuccess !== undefined) {
            this.isFirstScanSuccess = c12.isFirstScanSuccess;
        }
        if (c12.scanConsumed !== undefined) {
            this.scanConsumed = c12.scanConsumed;
        }
        if (c12.luminanceAnalyzerId !== undefined) {
            this.luminanceAnalyzerId = c12.luminanceAnalyzerId;
        }
        if (c12.callback !== undefined) {
            this.callback = c12.callback;
        }
    }
    updateStateVars(b12) {
        this.__albumsShow.reset(b12.albumsShow);
        this.__albumsIcon.reset(b12.albumsIcon);
        this.__albumsIconSize.reset(b12.albumsIconSize);
        this.__albumsText.reset(b12.albumsText);
        this.__albumsTextSize.reset(b12.albumsTextSize);
        this.__albumsTextColor.reset(b12.albumsTextColor);
        this.__lightShow.reset(b12.lightShow);
        this.__lightCloseIcon.reset(b12.lightCloseIcon);
        this.__lightOpenIcon.reset(b12.lightOpenIcon);
        this.__lightIconSize.reset(b12.lightIconSize);
        this.__lightOpenText.reset(b12.lightOpenText);
        this.__lightCloseText.reset(b12.lightCloseText);
        this.__lightTextSize.reset(b12.lightTextSize);
        this.__lightTextColor.reset(b12.lightTextColor);
        this.__tipsShow.reset(b12.tipsShow);
        this.__tips.reset(b12.tips);
        this.__tipsTextColor.reset(b12.tipsTextColor);
        this.__tipsTextSize.reset(b12.tipsTextSize);
        this.__tipsTopMargin.reset(b12.tipsTopMargin);
        this.__maskColor.reset(b12.maskColor);
        this.__scannerSize.reset(b12.scannerSize);
        this.__cornerLineWidth.reset(b12.cornerLineWidth);
        this.__cornerLineLength.reset(b12.cornerLineLength);
        this.__cornerLineColor.reset(b12.cornerLineColor);
        this.__cornerLineShow.reset(b12.cornerLineShow);
        this.__scanTopMargin.reset(b12.scanTopMargin);
        this.__scanLineWidth.reset(b12.scanLineWidth);
        this.__scanLineLength.reset(b12.scanLineLength);
        this.__scanLineColor.reset(b12.scanLineColor);
        this.__scanLineShow.reset(b12.scanLineShow);
        this.__scanAnimTime.reset(b12.scanAnimTime);
        this.__scanIntervalTime.reset(b12.scanIntervalTime);
        this.__onceScan.reset(b12.onceScan);
        this.__scanTypes.reset(b12.scanTypes);
        this.__safeAreaType.reset(b12.safeAreaType);
        this.__safeAreaEdge.reset(b12.safeAreaEdge);
        this.__luminanceAnalyzerInterval.reset(b12.luminanceAnalyzerInterval);
    }
    purgeVariableDependenciesOnElmtId(a12) {
        this.__albumsShow.purgeDependencyOnElmtId(a12);
        this.__albumsIcon.purgeDependencyOnElmtId(a12);
        this.__albumsIconSize.purgeDependencyOnElmtId(a12);
        this.__albumsText.purgeDependencyOnElmtId(a12);
        this.__albumsTextSize.purgeDependencyOnElmtId(a12);
        this.__albumsTextColor.purgeDependencyOnElmtId(a12);
        this.__lightShow.purgeDependencyOnElmtId(a12);
        this.__lightCloseIcon.purgeDependencyOnElmtId(a12);
        this.__lightOpenIcon.purgeDependencyOnElmtId(a12);
        this.__lightIconSize.purgeDependencyOnElmtId(a12);
        this.__lightOpenText.purgeDependencyOnElmtId(a12);
        this.__lightCloseText.purgeDependencyOnElmtId(a12);
        this.__lightTextSize.purgeDependencyOnElmtId(a12);
        this.__lightTextColor.purgeDependencyOnElmtId(a12);
        this.__tipsShow.purgeDependencyOnElmtId(a12);
        this.__tips.purgeDependencyOnElmtId(a12);
        this.__tipsTextColor.purgeDependencyOnElmtId(a12);
        this.__tipsTextSize.purgeDependencyOnElmtId(a12);
        this.__tipsTopMargin.purgeDependencyOnElmtId(a12);
        this.__maskColor.purgeDependencyOnElmtId(a12);
        this.__scannerSize.purgeDependencyOnElmtId(a12);
        this.__cornerLineWidth.purgeDependencyOnElmtId(a12);
        this.__cornerLineLength.purgeDependencyOnElmtId(a12);
        this.__cornerLineColor.purgeDependencyOnElmtId(a12);
        this.__cornerLineShow.purgeDependencyOnElmtId(a12);
        this.__scanTopMargin.purgeDependencyOnElmtId(a12);
        this.__scanLineWidth.purgeDependencyOnElmtId(a12);
        this.__scanLineLength.purgeDependencyOnElmtId(a12);
        this.__scanLineColor.purgeDependencyOnElmtId(a12);
        this.__scanLineShow.purgeDependencyOnElmtId(a12);
        this.__scanAnimTime.purgeDependencyOnElmtId(a12);
        this.__scanIntervalTime.purgeDependencyOnElmtId(a12);
        this.__onceScan.purgeDependencyOnElmtId(a12);
        this.__scanTypes.purgeDependencyOnElmtId(a12);
        this.__safeAreaType.purgeDependencyOnElmtId(a12);
        this.__safeAreaEdge.purgeDependencyOnElmtId(a12);
        this.__luminanceAnalyzerInterval.purgeDependencyOnElmtId(a12);
        this.__scanLineY.purgeDependencyOnElmtId(a12);
        this.__screenWidth.purgeDependencyOnElmtId(a12);
        this.__screenHeight.purgeDependencyOnElmtId(a12);
        this.__isLoaded.purgeDependencyOnElmtId(a12);
        this.__isLightOpen.purgeDependencyOnElmtId(a12);
        this.__scanRectLeftBoundary.purgeDependencyOnElmtId(a12);
        this.__scanRectRightBoundary.purgeDependencyOnElmtId(a12);
        this.__scanRectTopBoundary.purgeDependencyOnElmtId(a12);
        this.__scanRectBottomBoundary.purgeDependencyOnElmtId(a12);
        this.__firstShow.purgeDependencyOnElmtId(a12);
        this.__isRelease.purgeDependencyOnElmtId(a12);
        this.__isFirstScanSuccess.purgeDependencyOnElmtId(a12);
    }
    aboutToBeDeleted() {
        this.__albumsShow.aboutToBeDeleted();
        this.__albumsIcon.aboutToBeDeleted();
        this.__albumsIconSize.aboutToBeDeleted();
        this.__albumsText.aboutToBeDeleted();
        this.__albumsTextSize.aboutToBeDeleted();
        this.__albumsTextColor.aboutToBeDeleted();
        this.__lightShow.aboutToBeDeleted();
        this.__lightCloseIcon.aboutToBeDeleted();
        this.__lightOpenIcon.aboutToBeDeleted();
        this.__lightIconSize.aboutToBeDeleted();
        this.__lightOpenText.aboutToBeDeleted();
        this.__lightCloseText.aboutToBeDeleted();
        this.__lightTextSize.aboutToBeDeleted();
        this.__lightTextColor.aboutToBeDeleted();
        this.__tipsShow.aboutToBeDeleted();
        this.__tips.aboutToBeDeleted();
        this.__tipsTextColor.aboutToBeDeleted();
        this.__tipsTextSize.aboutToBeDeleted();
        this.__tipsTopMargin.aboutToBeDeleted();
        this.__maskColor.aboutToBeDeleted();
        this.__scannerSize.aboutToBeDeleted();
        this.__cornerLineWidth.aboutToBeDeleted();
        this.__cornerLineLength.aboutToBeDeleted();
        this.__cornerLineColor.aboutToBeDeleted();
        this.__cornerLineShow.aboutToBeDeleted();
        this.__scanTopMargin.aboutToBeDeleted();
        this.__scanLineWidth.aboutToBeDeleted();
        this.__scanLineLength.aboutToBeDeleted();
        this.__scanLineColor.aboutToBeDeleted();
        this.__scanLineShow.aboutToBeDeleted();
        this.__scanAnimTime.aboutToBeDeleted();
        this.__scanIntervalTime.aboutToBeDeleted();
        this.__onceScan.aboutToBeDeleted();
        this.__scanTypes.aboutToBeDeleted();
        this.__safeAreaType.aboutToBeDeleted();
        this.__safeAreaEdge.aboutToBeDeleted();
        this.__luminanceAnalyzerInterval.aboutToBeDeleted();
        this.__scanLineY.aboutToBeDeleted();
        this.__screenWidth.aboutToBeDeleted();
        this.__screenHeight.aboutToBeDeleted();
        this.__isLoaded.aboutToBeDeleted();
        this.__isLightOpen.aboutToBeDeleted();
        this.__scanRectLeftBoundary.aboutToBeDeleted();
        this.__scanRectRightBoundary.aboutToBeDeleted();
        this.__scanRectTopBoundary.aboutToBeDeleted();
        this.__scanRectBottomBoundary.aboutToBeDeleted();
        this.__firstShow.aboutToBeDeleted();
        this.__isRelease.aboutToBeDeleted();
        this.__isFirstScanSuccess.aboutToBeDeleted();
        SubscriberManager.Get().delete(this.id__());
        this.aboutToBeDeletedInternal();
    }
    get albumsShow() {
        return this.__albumsShow.get();
    }
    set albumsShow(z11) {
        this.__albumsShow.set(z11);
    }
    get albumsIcon() {
        return this.__albumsIcon.get();
    }
    set albumsIcon(y11) {
        this.__albumsIcon.set(y11);
    }
    get albumsIconSize() {
        return this.__albumsIconSize.get();
    }
    set albumsIconSize(x11) {
        this.__albumsIconSize.set(x11);
    }
    get albumsText() {
        return this.__albumsText.get();
    }
    set albumsText(w11) {
        this.__albumsText.set(w11);
    }
    get albumsTextSize() {
        return this.__albumsTextSize.get();
    }
    set albumsTextSize(v11) {
        this.__albumsTextSize.set(v11);
    }
    get albumsTextColor() {
        return this.__albumsTextColor.get();
    }
    set albumsTextColor(u11) {
        this.__albumsTextColor.set(u11);
    }
    get lightShow() {
        return this.__lightShow.get();
    }
    set lightShow(t11) {
        this.__lightShow.set(t11);
    }
    get lightCloseIcon() {
        return this.__lightCloseIcon.get();
    }
    set lightCloseIcon(s11) {
        this.__lightCloseIcon.set(s11);
    }
    get lightOpenIcon() {
        return this.__lightOpenIcon.get();
    }
    set lightOpenIcon(r11) {
        this.__lightOpenIcon.set(r11);
    }
    get lightIconSize() {
        return this.__lightIconSize.get();
    }
    set lightIconSize(q11) {
        this.__lightIconSize.set(q11);
    }
    get lightOpenText() {
        return this.__lightOpenText.get();
    }
    set lightOpenText(p11) {
        this.__lightOpenText.set(p11);
    }
    get lightCloseText() {
        return this.__lightCloseText.get();
    }
    set lightCloseText(o11) {
        this.__lightCloseText.set(o11);
    }
    get lightTextSize() {
        return this.__lightTextSize.get();
    }
    set lightTextSize(n11) {
        this.__lightTextSize.set(n11);
    }
    get lightTextColor() {
        return this.__lightTextColor.get();
    }
    set lightTextColor(m11) {
        this.__lightTextColor.set(m11);
    }
    get tipsShow() {
        return this.__tipsShow.get();
    }
    set tipsShow(l11) {
        this.__tipsShow.set(l11);
    }
    get tips() {
        return this.__tips.get();
    }
    set tips(k11) {
        this.__tips.set(k11);
    }
    get tipsTextColor() {
        return this.__tipsTextColor.get();
    }
    set tipsTextColor(j11) {
        this.__tipsTextColor.set(j11);
    }
    get tipsTextSize() {
        return this.__tipsTextSize.get();
    }
    set tipsTextSize(i11) {
        this.__tipsTextSize.set(i11);
    }
    get tipsTopMargin() {
        return this.__tipsTopMargin.get();
    }
    set tipsTopMargin(h11) {
        this.__tipsTopMargin.set(h11);
    }
    get maskColor() {
        return this.__maskColor.get();
    }
    set maskColor(g11) {
        this.__maskColor.set(g11);
    }
    get scannerSize() {
        return this.__scannerSize.get();
    }
    set scannerSize(f11) {
        this.__scannerSize.set(f11);
    }
    get cornerLineWidth() {
        return this.__cornerLineWidth.get();
    }
    set cornerLineWidth(e11) {
        this.__cornerLineWidth.set(e11);
    }
    get cornerLineLength() {
        return this.__cornerLineLength.get();
    }
    set cornerLineLength(d11) {
        this.__cornerLineLength.set(d11);
    }
    get cornerLineColor() {
        return this.__cornerLineColor.get();
    }
    set cornerLineColor(c11) {
        this.__cornerLineColor.set(c11);
    }
    get cornerLineShow() {
        return this.__cornerLineShow.get();
    }
    set cornerLineShow(b11) {
        this.__cornerLineShow.set(b11);
    }
    get scanTopMargin() {
        return this.__scanTopMargin.get();
    }
    set scanTopMargin(a11) {
        this.__scanTopMargin.set(a11);
    }
    get scanLineWidth() {
        return this.__scanLineWidth.get();
    }
    set scanLineWidth(z10) {
        this.__scanLineWidth.set(z10);
    }
    get scanLineLength() {
        return this.__scanLineLength.get();
    }
    set scanLineLength(y10) {
        this.__scanLineLength.set(y10);
    }
    get scanLineColor() {
        return this.__scanLineColor.get();
    }
    set scanLineColor(x10) {
        this.__scanLineColor.set(x10);
    }
    get scanLineShow() {
        return this.__scanLineShow.get();
    }
    set scanLineShow(w10) {
        this.__scanLineShow.set(w10);
    }
    get scanAnimTime() {
        return this.__scanAnimTime.get();
    }
    set scanAnimTime(v10) {
        this.__scanAnimTime.set(v10);
    }
    get scanIntervalTime() {
        return this.__scanIntervalTime.get();
    }
    set scanIntervalTime(u10) {
        this.__scanIntervalTime.set(u10);
    }
    get onceScan() {
        return this.__onceScan.get();
    }
    set onceScan(t10) {
        this.__onceScan.set(t10);
    }
    get scanTypes() {
        return this.__scanTypes.get();
    }
    set scanTypes(s10) {
        this.__scanTypes.set(s10);
    }
    get safeAreaType() {
        return this.__safeAreaType.get();
    }
    set safeAreaType(r10) {
        this.__safeAreaType.set(r10);
    }
    get safeAreaEdge() {
        return this.__safeAreaEdge.get();
    }
    set safeAreaEdge(q10) {
        this.__safeAreaEdge.set(q10);
    }
    get luminanceAnalyzerInterval() {
        return this.__luminanceAnalyzerInterval.get();
    }
    set luminanceAnalyzerInterval(p10) {
        this.__luminanceAnalyzerInterval.set(p10);
    }
    get scanLineY() {
        return this.__scanLineY.get();
    }
    set scanLineY(o10) {
        this.__scanLineY.set(o10);
    }
    get screenWidth() {
        return this.__screenWidth.get();
    }
    set screenWidth(n10) {
        this.__screenWidth.set(n10);
    }
    get screenHeight() {
        return this.__screenHeight.get();
    }
    set screenHeight(m10) {
        this.__screenHeight.set(m10);
    }
    get isLoaded() {
        return this.__isLoaded.get();
    }
    set isLoaded(l10) {
        this.__isLoaded.set(l10);
    }
    get isLightOpen() {
        return this.__isLightOpen.get();
    }
    set isLightOpen(k10) {
        this.__isLightOpen.set(k10);
    }
    get scanRectLeftBoundary() {
        return this.__scanRectLeftBoundary.get();
    }
    set scanRectLeftBoundary(j10) {
        this.__scanRectLeftBoundary.set(j10);
    }
    get scanRectRightBoundary() {
        return this.__scanRectRightBoundary.get();
    }
    set scanRectRightBoundary(i10) {
        this.__scanRectRightBoundary.set(i10);
    }
    get scanRectTopBoundary() {
        return this.__scanRectTopBoundary.get();
    }
    set scanRectTopBoundary(h10) {
        this.__scanRectTopBoundary.set(h10);
    }
    get scanRectBottomBoundary() {
        return this.__scanRectBottomBoundary.get();
    }
    set scanRectBottomBoundary(g10) {
        this.__scanRectBottomBoundary.set(g10);
    }
    get firstShow() {
        return this.__firstShow.get();
    }
    set firstShow(f10) {
        this.__firstShow.set(f10);
    }
    get isRelease() {
        return this.__isRelease.get();
    }
    set isRelease(e10) {
        this.__isRelease.set(e10);
    }
    get isFirstScanSuccess() {
        return this.__isFirstScanSuccess.get();
    }
    set isFirstScanSuccess(d10) {
        this.__isFirstScanSuccess.set(d10);
    }
    aboutToAppear() {
        this.controller?.init(this);
        this.scanRectLeftBoundary = (this.screenWidth - this.scannerSize) / 2.0;
        this.scanRectRightBoundary = this.scanRectLeftBoundary + this.scannerSize;
        this.scanRectTopBoundary = this.scanTopMargin + this.cornerLineWidth;
        this.scanRectBottomBoundary = this.scanRectTopBoundary + this.scannerSize;
    }
    aboutToDisappear() {
        this.releaseScan();
    }
    pickPhoto() {
        const a10 = new photoAccessHelper.PhotoSelectOptions();
        a10.MIMEType = photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE;
        a10.maxSelectNumber = 1;
        const b10 = new photoAccessHelper.PhotoViewPicker();
        b10.select(a10).then(async (c10) => {
            this.scanUri(c10.photoUris[0]);
        });
    }
    openLight() {
        if (this.isLoaded && !this.isLightOpen) {
            try {
                customScan.openFlashLight();
            }
            catch (z9) {
                console.warn(z9);
            }
            this.isLightOpen = true;
        }
    }
    closeLight() {
        if (this.isLoaded && this.isLightOpen) {
            try {
                customScan.closeFlashLight();
            }
            catch (y9) {
                console.warn(y9);
            }
            this.isLightOpen = false;
        }
    }
    toggleLight() {
        if (this.isLoaded) {
            try {
                if (this.isLightOpen) {
                    customScan.closeFlashLight();
                }
                else {
                    customScan.openFlashLight();
                }
            }
            catch (x9) {
                console.warn(x9);
            }
            this.isLightOpen = !this.isLightOpen;
        }
    }
    setZoom(v9) {
        try {
            customScan.setZoom(v9);
        }
        catch (w9) {
            console.warn(w9);
        }
    }
    getZoom() {
        try {
            return customScan.getZoom();
        }
        catch (u9) {
            console.warn(u9);
            return 0;
        }
    }
    getLightStatus() {
        try {
            return customScan.getFlashLightStatus();
        }
        catch (t9) {
            console.warn(t9);
            return false;
        }
    }
    startScan() {
        this.scanLineY = this.scannerSize;
        if (this.isLoaded) {
            if (this.viewControl != undefined) {
                this.checkPermissionAndInitCamera();
            }
        }
        else {
            this.releaseScan();
        }
    }
    scanUrl(q9, r9 = {
        scanTypes: this.scanTypes,
        enableMultiMode: true,
        enableAlbum: true
    }) {
        const s9 = ScanUtil.scanUrl(getContext(this), q9, r9);
        this.scanPromiseHandler(s9);
    }
    scanPixelMap(n9, o9 = {
        scanTypes: this.scanTypes,
        enableMultiMode: true,
        enableAlbum: true
    }) {
        const p9 = ScanUtil.scanPixelMap(getContext(this), n9, o9);
        this.scanPromiseHandler(p9);
    }
    scanUri(k9, l9 = {
        scanTypes: this.scanTypes,
        enableMultiMode: true,
        enableAlbum: true
    }) {
        const m9 = ScanUtil.scanUri(k9, l9);
        this.scanPromiseHandler(m9);
    }
    scanPromiseHandler(h9) {
        h9.then((j9) => {
            this.onScanResult?.(ResultState.Success, j9);
        }).catch((i9) => {
            this.onScanResult?.(ResultState.Fail, i9);
        });
    }
    isInScanRect(d9, e9, f9, g9) {
        if ((d9 > this.scanRectLeftBoundary - this.areaOffset)
            && (e9 > this.scanRectTopBoundary - this.areaOffset)
            && (f9 < this.scanRectRightBoundary + this.areaOffset)
            && (g9 < this.scanRectBottomBoundary + this.areaOffset)) {
            return true;
        }
        else {
            return false;
        }
    }
    rescan() {
        setTimeout(() => {
            if (!this.isRelease) {
                try {
                    customScan.stop().then(() => {
                        customScan.start(this.viewControl, this.callback);
                    }).catch(() => {
                        customScan.start(this.viewControl, this.callback);
                    });
                    this.isRelease = false;
                }
                catch (c9) {
                    console.warn(c9);
                }
            }
        }, this.scanIntervalTime);
    }
    checkPermissionAndInitCamera() {
        requestPermissionsFromUser(getContext(this), 'ohos.permission.CAMERA')
            .then(() => {
            this.onCameraGrant?.();
            if (canIUse('SystemCapability.Multimedia.Scan.Core')) {
                let a9 = {
                    scanTypes: this.scanTypes,
                    enableMultiMode: false,
                    enableAlbum: true
                };
                try {
                    if (this.scanConsumed) {
                        customScan.init(a9);
                        customScan.start(this.viewControl, this.callback);
                        this.scanConsumed = false;
                        this.isRelease = false;
                    }
                }
                catch (b9) {
                    console.warn(b9);
                }
            }
            else {
                console.warn('不支持扫码');
                return;
            }
        }).catch(() => {
            this.onCameraReject?.();
            console.warn('初始化相机异常');
        });
    }
    releaseScan() {
        this.isRelease = true;
        this.scanConsumed = true;
        try {
            if (canIUse('SystemCapability.Multimedia.Scan.Core')) {
                customScan.stop().then(() => {
                    console.log('相机停止成功');
                }).catch((z8) => {
                });
                customScan.release().then(() => {
                    console.log('相机释放成功');
                }).catch((y8) => {
                });
            }
            else {
                console.warn('不支持扫码');
                return;
            }
        }
        catch (x8) {
            console.warn(x8);
        }
    }
    startAnalyzer() {
        if (!this.luminanceAnalyzerId) {
            this.luminanceAnalyzerId = setInterval(() => {
                image.createPixelMapFromSurface(this.surfaceId, { x: 0, y: 0, size: { height: this.defaultHeight, width: this.defaultHeight } }).then((v8) => {
                    calculateLuminance(v8).then((w8) => {
                        this.luminanceListener?.(w8);
                    });
                });
            }, this.luminanceAnalyzerInterval);
        }
    }
    initialRender() {
        this.observeComponentCreation2((p8, q8) => {
            Stack.create();
            Stack.backgroundColor(Color.Black);
            Stack.onSizeChange((t8, u8) => {
                this.screenWidth = u8.width;
                this.screenHeight = u8.height;
            });
            Stack.onVisibleAreaChange([0.0, 1.0], (r8, s8) => {
                if (r8 && (s8 >= 1.0 || (s8 > 0.9 && this.safeAreaType &&
                    this.safeAreaType?.length > 0 && this.safeAreaEdge && this.safeAreaEdge.length > 0))) {
                    if (!this.firstShow) {
                        this.startScan();
                    }
                    this.firstShow = false;
                    if (this.luminanceListener) {
                        this.startAnalyzer();
                    }
                }
                if (!r8 && s8 <= 0) {
                    this.releaseScan();
                    if (this.luminanceAnalyzerId) {
                        clearInterval(this.luminanceAnalyzerId);
                        this.luminanceAnalyzerId = 0;
                    }
                }
            });
            Stack.expandSafeArea(ObservedObject.GetRawObject(this.safeAreaType), ObservedObject.GetRawObject(this.safeAreaEdge));
        }, Stack);
        this.Camera.bind(this)();
        this.Mask.bind(this)();
        this.ScannerLayout.bind(this)();
        this.ButtonLayout.bind(this)();
        Stack.pop();
    }
    ButtonLayout(u7 = null) {
        this.observeComponentCreation2((n8, o8) => {
            Column.create();
            Column.height('100%');
            Column.width('100%');
            Column.justifyContent(FlexAlign.End);
            Column.hitTestBehavior(HitTestMode.Transparent);
        }, Column);
        this.observeComponentCreation2((l8, m8) => {
            Row.create();
            Row.margin({ bottom: 20 });
        }, Row);
        this.observeComponentCreation2((j8, k8) => {
            Column.create();
            Column.visibility(this.albumsShow ? Visibility.Visible : Visibility.None);
            Column.onClick(() => {
                this.pickPhoto();
            });
        }, Column);
        this.observeComponentCreation2((h8, i8) => {
            Image.create(this.albumsIcon);
            Image.height(ObservedObject.GetRawObject(this.albumsIconSize));
            Image.width(ObservedObject.GetRawObject(this.albumsIconSize));
        }, Image);
        this.observeComponentCreation2((f8, g8) => {
            Text.create(this.albumsText);
            Text.fontSize(ObservedObject.GetRawObject(this.albumsTextSize));
            Text.fontColor(ObservedObject.GetRawObject(this.albumsTextColor));
            Text.margin({ top: 4, bottom: 10 });
        }, Text);
        Text.pop();
        Column.pop();
        this.observeComponentCreation2((b8, c8) => {
            If.create();
            if (this.albumsShow && this.lightShow) {
                this.ifElseBranchUpdateFunction(0, () => {
                    this.observeComponentCreation2((d8, e8) => {
                        Divider.create();
                        Divider.vertical(true);
                        Divider.strokeWidth(10);
                        Divider.color(Color.Transparent);
                        Divider.width(81);
                        Divider.height(ObservedObject.GetRawObject(this.albumsIconSize));
                    }, Divider);
                });
            }
            else {
                this.ifElseBranchUpdateFunction(1, () => {
                });
            }
        }, If);
        If.pop();
        this.observeComponentCreation2((z7, a8) => {
            Column.create();
            Column.visibility(this.lightShow ? Visibility.Visible : Visibility.None);
            Column.onClick(() => {
                this.toggleLight();
            });
        }, Column);
        this.observeComponentCreation2((x7, y7) => {
            Image.create(this.isLightOpen ? this.lightOpenIcon : this.lightCloseIcon);
            Image.height(ObservedObject.GetRawObject(this.lightIconSize));
            Image.width(ObservedObject.GetRawObject(this.lightIconSize));
        }, Image);
        this.observeComponentCreation2((v7, w7) => {
            Text.create(this.isLightOpen ? this.lightOpenText : this.lightCloseText);
            Text.fontSize(ObservedObject.GetRawObject(this.lightTextSize));
            Text.fontColor(ObservedObject.GetRawObject(this.lightTextColor));
            Text.margin({ top: 4, bottom: 10 });
        }, Text);
        Text.pop();
        Column.pop();
        Row.pop();
        Column.pop();
    }
    ScannerLayout(p7 = null) {
        this.observeComponentCreation2((s7, t7) => {
            Column.create();
            Column.width('100%');
            Column.height('100%');
            Column.hitTestBehavior(HitTestMode.Transparent);
        }, Column);
        this.Scanner.bind(this)();
        this.observeComponentCreation2((q7, r7) => {
            Text.create(this.tips);
            Text.fontColor(ObservedObject.GetRawObject(this.tipsTextColor));
            Text.fontSize(ObservedObject.GetRawObject(this.tipsTextSize));
            Text.visibility(this.tipsShow ? Visibility.Visible : Visibility.None);
            Text.margin({ top: this.tipsTopMargin });
        }, Text);
        Text.pop();
        Column.pop();
    }
    Scanner(i6 = null) {
        this.observeComponentCreation2((n7, o7) => {
            RelativeContainer.create();
            RelativeContainer.width(this.scannerSize + (this.cornerLineWidth * 2));
            RelativeContainer.height(this.scannerSize + (this.cornerLineWidth * 2));
            RelativeContainer.margin({ top: this.scanTopMargin });
        }, RelativeContainer);
        this.observeComponentCreation2((l7, m7) => {
            __Common__.create();
            __Common__.alignRules({
                top: { anchor: 'topRect', align: VerticalAlign.Bottom },
                left: { anchor: 'leftRect', align: HorizontalAlign.End }
            });
            __Common__.id('scanTopLeftRect');
            __Common__.visibility(this.cornerLineShow ? Visibility.Visible : Visibility.None);
        }, __Common__);
        {
            this.observeComponentCreation2((h7, i7) => {
                if (i7) {
                    let j7 = new ScanTopLeftRect(this, {
                        cornerLineWidth: this.cornerLineWidth,
                        cornerLineLength: this.cornerLineLength,
                        cornerLineColor: this.cornerLineColor
                    }, undefined, h7, () => { }, { page: "Scanner/src/main/ets/components/Scanner.ets", line: 528, col: 7 });
                    ViewPU.create(j7);
                    let k7 = () => {
                        return {
                            cornerLineWidth: this.cornerLineWidth,
                            cornerLineLength: this.cornerLineLength,
                            cornerLineColor: this.cornerLineColor
                        };
                    };
                    j7.paramsGenerator_ = k7;
                }
                else {
                    this.updateStateVarsOfChildByElmtId(h7, {
                        cornerLineWidth: this.cornerLineWidth,
                        cornerLineLength: this.cornerLineLength,
                        cornerLineColor: this.cornerLineColor
                    });
                }
            }, { name: "ScanTopLeftRect" });
        }
        __Common__.pop();
        this.observeComponentCreation2((f7, g7) => {
            __Common__.create();
            __Common__.alignRules({
                top: { anchor: 'topRect', align: VerticalAlign.Bottom },
                right: { anchor: 'rightRect', align: HorizontalAlign.Start }
            });
            __Common__.id('scanTopRightRect');
            __Common__.alignRules({
                top: {
                    anchor: '__container__',
                    align: VerticalAlign.Top
                },
                right: {
                    anchor: '__container__',
                    align: HorizontalAlign.End
                }
            });
            __Common__.visibility(this.cornerLineShow ? Visibility.Visible : Visibility.None);
        }, __Common__);
        {
            this.observeComponentCreation2((b7, c7) => {
                if (c7) {
                    let d7 = new ScanTopRightRect(this, {
                        cornerLineWidth: this.cornerLineWidth,
                        cornerLineLength: this.cornerLineLength,
                        cornerLineColor: this.cornerLineColor
                    }, undefined, b7, () => { }, { page: "Scanner/src/main/ets/components/Scanner.ets", line: 538, col: 7 });
                    ViewPU.create(d7);
                    let e7 = () => {
                        return {
                            cornerLineWidth: this.cornerLineWidth,
                            cornerLineLength: this.cornerLineLength,
                            cornerLineColor: this.cornerLineColor
                        };
                    };
                    d7.paramsGenerator_ = e7;
                }
                else {
                    this.updateStateVarsOfChildByElmtId(b7, {
                        cornerLineWidth: this.cornerLineWidth,
                        cornerLineLength: this.cornerLineLength,
                        cornerLineColor: this.cornerLineColor
                    });
                }
            }, { name: "ScanTopRightRect" });
        }
        __Common__.pop();
        this.observeComponentCreation2((z6, a7) => {
            __Common__.create();
            __Common__.alignRules({
                bottom: { anchor: 'bottomRect', align: VerticalAlign.Top },
                left: { anchor: 'leftRect', align: HorizontalAlign.End }
            });
            __Common__.id('ScanBottomRightRect');
            __Common__.alignRules({
                bottom: {
                    anchor: '__container__',
                    align: VerticalAlign.Bottom
                },
                left: {
                    anchor: '__container__',
                    align: HorizontalAlign.Start
                }
            });
            __Common__.visibility(this.cornerLineShow ? Visibility.Visible : Visibility.None);
        }, __Common__);
        {
            this.observeComponentCreation2((v6, w6) => {
                if (w6) {
                    let x6 = new ScanBottomLeftRect(this, {
                        cornerLineWidth: this.cornerLineWidth,
                        cornerLineLength: this.cornerLineLength,
                        cornerLineColor: this.cornerLineColor
                    }, undefined, v6, () => { }, { page: "Scanner/src/main/ets/components/Scanner.ets", line: 558, col: 7 });
                    ViewPU.create(x6);
                    let y6 = () => {
                        return {
                            cornerLineWidth: this.cornerLineWidth,
                            cornerLineLength: this.cornerLineLength,
                            cornerLineColor: this.cornerLineColor
                        };
                    };
                    x6.paramsGenerator_ = y6;
                }
                else {
                    this.updateStateVarsOfChildByElmtId(v6, {
                        cornerLineWidth: this.cornerLineWidth,
                        cornerLineLength: this.cornerLineLength,
                        cornerLineColor: this.cornerLineColor
                    });
                }
            }, { name: "ScanBottomLeftRect" });
        }
        __Common__.pop();
        this.observeComponentCreation2((t6, u6) => {
            __Common__.create();
            __Common__.alignRules({
                bottom: { anchor: 'bottomRect', align: VerticalAlign.Top },
                right: { anchor: 'rightRect', align: HorizontalAlign.Start }
            });
            __Common__.id('scanBottomRightRect');
            __Common__.alignRules({
                bottom: {
                    anchor: '__container__',
                    align: VerticalAlign.Bottom
                },
                right: {
                    anchor: '__container__',
                    align: HorizontalAlign.End
                }
            });
            __Common__.visibility(this.cornerLineShow ? Visibility.Visible : Visibility.None);
        }, __Common__);
        {
            this.observeComponentCreation2((p6, q6) => {
                if (q6) {
                    let r6 = new ScanBottomRightRect(this, {
                        cornerLineWidth: this.cornerLineWidth,
                        cornerLineLength: this.cornerLineLength,
                        cornerLineColor: this.cornerLineColor
                    }, undefined, p6, () => { }, { page: "Scanner/src/main/ets/components/Scanner.ets", line: 578, col: 7 });
                    ViewPU.create(r6);
                    let s6 = () => {
                        return {
                            cornerLineWidth: this.cornerLineWidth,
                            cornerLineLength: this.cornerLineLength,
                            cornerLineColor: this.cornerLineColor
                        };
                    };
                    r6.paramsGenerator_ = s6;
                }
                else {
                    this.updateStateVarsOfChildByElmtId(p6, {
                        cornerLineWidth: this.cornerLineWidth,
                        cornerLineLength: this.cornerLineLength,
                        cornerLineColor: this.cornerLineColor
                    });
                }
            }, { name: "ScanBottomRightRect" });
        }
        __Common__.pop();
        this.observeComponentCreation2((n6, o6) => {
            Column.create();
            Column.width(this.scannerSize);
            Column.height(this.scannerSize);
            Column.visibility(this.scanLineY > 0 ? Visibility.Visible : Visibility.Hidden);
            Column.id("contain");
            Column.alignRules({
                center: {
                    anchor: '__container__',
                    align: VerticalAlign.Center
                },
                middle: {
                    anchor: '__container__',
                    align: HorizontalAlign.Center
                }
            });
        }, Column);
        this.observeComponentCreation2((j6, k6) => {
            If.create();
            if (this.scanLineShow) {
                this.ifElseBranchUpdateFunction(0, () => {
                    this.observeComponentCreation2((l6, m6) => {
                        Line.create();
                        Context.animation({
                            duration: this.scanAnimTime,
                            iterations: -1,
                            curve: Curve.Linear,
                            playMode: PlayMode.Normal,
                        });
                        Line.width(ObservedObject.GetRawObject(this.scanLineLength));
                        Line.height(ObservedObject.GetRawObject(this.scanLineWidth));
                        Line.backgroundColor(ObservedObject.GetRawObject(this.scanLineColor));
                        Line.alignRules({
                            top: { anchor: 'topRect', align: VerticalAlign.Bottom },
                            middle: { anchor: '__container__', align: HorizontalAlign.Center },
                        });
                        Line.translate({ y: this.scanLineY });
                        Context.animation(null);
                    }, Line);
                });
            }
            else {
                this.ifElseBranchUpdateFunction(1, () => {
                });
            }
        }, If);
        If.pop();
        Column.pop();
        RelativeContainer.pop();
    }
    Mask(v5 = null) {
        this.observeComponentCreation2((g6, h6) => {
            Column.create();
            Column.hitTestBehavior(HitTestMode.Transparent);
            Column.width(this.screenWidth);
            Column.height(this.screenHeight);
            Column.position({ x: 0, y: 0 });
        }, Column);
        this.observeComponentCreation2((e6, f6) => {
            Row.create();
            Row.backgroundColor(ObservedObject.GetRawObject(this.maskColor));
            Row.width('100%');
            Row.height(this.scanTopMargin + this.cornerLineWidth);
        }, Row);
        Row.pop();
        this.observeComponentCreation2((c6, d6) => {
            Row.create();
            Row.justifyContent(FlexAlign.SpaceBetween);
            Row.width('100%');
        }, Row);
        this.observeComponentCreation2((a6, b6) => {
            Row.create();
            Row.backgroundColor(ObservedObject.GetRawObject(this.maskColor));
            Row.width((this.screenWidth - this.scannerSize) / 2);
            Row.height(Math.min(this.scannerSize, this.screenHeight - (this.scanTopMargin + this.cornerLineWidth)));
        }, Row);
        Row.pop();
        this.observeComponentCreation2((y5, z5) => {
            Row.create();
            Row.backgroundColor(ObservedObject.GetRawObject(this.maskColor));
            Row.width((this.screenWidth - this.scannerSize) / 2);
            Row.height(Math.min(this.scannerSize, this.screenHeight - (this.scanTopMargin + this.cornerLineWidth)));
        }, Row);
        Row.pop();
        Row.pop();
        this.observeComponentCreation2((w5, x5) => {
            Row.create();
            Row.backgroundColor(ObservedObject.GetRawObject(this.maskColor));
            Row.width('100%');
            Row.layoutWeight(1);
        }, Row);
        Row.pop();
        Column.pop();
    }
    Camera(q5 = null) {
        this.observeComponentCreation2((r5, s5) => {
            XComponent.create({
                id: 'componentId',
                type: XComponentType.SURFACE,
                controller: this.mXComponentController
            }, "__harDefaultBundleName__/__harDefaultModuleName__");
            XComponent.onLoad(() => {
                this.surfaceId = this.mXComponentController.getXComponentSurfaceId();
                this.mXComponentController.setXComponentSurfaceRect({
                    surfaceWidth: display.getDefaultDisplaySync().height * (this.defaultWidth / this.defaultHeight),
                    surfaceHeight: display.getDefaultDisplaySync().height
                });
                this.viewControl = {
                    width: this.screenWidth,
                    height: this.screenHeight,
                    surfaceId: this.surfaceId
                };
                this.isLoaded = true;
                this.startScan();
            });
            XComponent.backgroundColor(Color.Transparent);
            XComponent.width(this.screenWidth);
            XComponent.height(this.screenHeight);
            XComponent.position({ x: 0, y: 0 });
            Gesture.create(GesturePriority.Low);
            PinchGesture.create();
            PinchGesture.onActionUpdate((t5) => {
                if (this.isLoaded) {
                    try {
                        customScan.setZoom(customScan.getZoom() * t5.scale);
                    }
                    catch (u5) {
                        console.warn(u5);
                    }
                }
            });
            PinchGesture.pop();
            Gesture.pop();
        }, XComponent);
    }
    rerender() {
        this.updateDirtyElements();
    }
}
export class ScannerController {
    init(p5) {
        this.scanner = p5;
    }
    openLight() {
        this.scanner?.openLight();
    }
    closeLight() {
        this.scanner?.closeLight();
    }
    toggleLight() {
        this.scanner?.toggleLight();
    }
    pickPhoto() {
        this.scanner?.pickPhoto();
    }
    setZoom(o5) {
        this.scanner?.setZoom(o5);
    }
    getZoom() {
        return this.scanner?.getZoom() ?? 0;
    }
    getLightStatus() {
        return this.scanner?.getLightStatus() ?? false;
    }
    releaseScan() {
        this.scanner?.releaseScan();
    }
    startScan() {
        this.scanner?.startScan();
    }
    rescan() {
        this.scanner?.rescan();
    }
    scanUri(n5) {
        this.scanner?.scanUri(n5);
    }
    scanUrl(m5) {
        this.scanner?.scanUrl(m5);
    }
    scanPixelMap(l5) {
        this.scanner?.scanPixelMap(l5);
    }
}
